/*
 * 菜单
 *
 * @Author:    1024创新实验室-主任：卓大
 * @Date:      2022-09-03 22:00:32
 * @Wechat:    zhuda1024
 * @Email:     lab1024@163.com
 * @Copyright  1024创新实验室 （ https://1024lab.net ），Since 2012
 */
import { getRequest, postRequest, putRequest, deleteRequest } from '/src/lib/axios';

const baseUrl = "/api/sys/menu"

export const menuApi = {
  /**
   * 获取当前用户的树形菜单
   */
  getMenu: () => {
    return getRequest({
      url: baseUrl,
    });
  },
  /**
   * 添加菜单
   */
  addMenu: (param) => {
    return postRequest({
      url: baseUrl,
      data: param
    });
  },

  /**
   * 更新菜单
   */
  updateMenu: (param) => {
    return putRequest({
      url: baseUrl,
      data: param
    });
  },

  /**
   * 批量删除菜单
   */
  batchDeleteMenu: (id) => {
    return deleteRequest({
      url: baseUrl + "/" + id
    });
  },

  querySelfMenu: () => {
    return getRequest({
      url: baseUrl
    });
  },

  /**
   * 查询所有菜单列表
   */
  queryMenu: () => {
    return getRequest({
      url: baseUrl + '/tree'
    });
  },

  /**
   * 根据角色获取菜单ids
   */
  queryMenuByRoleId: (id) => {
    return getRequest({
      url: baseUrl + '/tree/' + id
    });
  },

  /**
   * 获取所有请求路径
   */
  getAuthUrl: () => {
    return getRequest({
      url: "/menu/auth/url"
    });
  },
};
